package sms_validate_service

import (
	"time"
	"hytx_media/models"
)

type SMSValidate struct {
	Type		 int
	MobilePhone	string
	DeadLine	time.Time
	MsgCode		string
	IsValided		int
	IsSended		int
	TempId			string
	Data		string
	ResultInfo		string

}

func (s *SMSValidate) Add() error {

	sms_validate := map[string]interface{}{
		`type` 			: s.Type,
		`mobile_phone`	: s.MobilePhone,
		`dead_line` 	: s.DeadLine,
		`msg_code` 		: s.MsgCode,
		`is_valided`	: s.IsValided,
		`is_sended`		: s.IsSended,
		`temp_id` 		: s.TempId,
		`data` 			: s.Data,
		`result_info` 	: s.ResultInfo,
	}

	if err := models.SMSValidateAdd(sms_validate); err != nil {
		return err
	}

	return nil
}

// 查询

func (s *SMSValidate) Select() (models.SmsValidate, error) {
	return models.SelectSMSValidate(s.MobilePhone)
}